<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise</title>
</head>

<body>
    <script>
        // promise  base
        // var pro = new Promise((resolve, reject) => {
        //     resolve('Promise doing...')
        //         // reject('Promsie fail...')
        // })

        // pro.then(value => {
        //     console.log("fulled", value);
        // }, reason => {
        //     console.log("rejected", reason);
        // })

        // Promise.all()：
        // 环境：通常在启动多个异步任务并发运行并为其结果创建承诺之后使用，以便人们可以等待所有任务完成。
        // const pro1 = Promise.resolve(3);
        // const pro2 = 44;
        // const pro3 = new Promise((resolve, reject) => {
        //     setTimeout(resolve, 100, 'foo')
        // })

        // Promise.all([pro1, pro2, pro3]).then(values => {
        //     console.log('Promise all :', values);
        // })

        var promise = new Promise((resolve, reject) => {
            resolve(100);
        })
        var pro1 = promise.then(value => {
            console.log(value);
            return pro1
        })

        pro1.then(value => {}, reason => {
            console.log(reason.message);
        })
    </script>
</body>

</html>